<!doctype html>
<html class="no-js" lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>添加员工</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">


    <!-- Bootstrap CSS
        ============================================ -->
    <link rel="stylesheet" type="text/css"  th:href="@{/css/bootstrap1.min.css}">
    <!-- Bootstrap CSS
        ============================================ -->
    <link rel="stylesheet" type="text/css"  th:href="@{/css/font-awesome.min.css}">

    <!-- normalize CSS
        ============================================ -->
    <link rel="stylesheet" type="text/css"  th:href="@{/css/data-table/bootstrap-table.css}">
    <link rel="stylesheet" type="text/css"  th:href="@{/css/data-table/bootstrap-editable.css}">
    <!-- style CSS
        ============================================ -->
    <link rel="stylesheet" type="text/css"  th:href="@{/css/style.css}">
    <!-- responsive CSS
        ============================================ -->
    <link rel="stylesheet" type="text/css"  th:href="@{/css/responsive.css}">
    <!-- modernizr JS
        ============================================ -->
    <script src="/js/vendor/modernizr-2.8.3.min.js" th:src="@{/js/vendor/modernizr-2.8.3.min.js}"></script>

    <!-- jquery
        ============================================ -->
    <script src="/js/vendor/jquery-1.12.4.min.js" th:src="@{/js/vendor/jquery-1.12.4.min.js}" ></script>
    <!-- bootstrap JS
        ============================================ -->
    <script src="/js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>

    <!-- data table JS
        ============================================ -->
    <script src="/js/data-table/bootstrap-table.js" th:src="@{/js/data-table/bootstrap-table.js}"></script>
    <script src="/js/data-table/tableExport.js" th:src="@{/js/data-table/tableExport.js}"></script>
    <script src="/js/data-table/data-table-active.js" th:src="@{/js/data-table/data-table-active.js}"></script>
    <script src="/js/data-table/bootstrap-table-editable.js" th:src="@{/js/data-table/bootstrap-table-editable.js}"></script>
    <script src="/js/data-table/bootstrap-editable.js" th:src="@{/js/data-table/bootstrap-editable.js}"></script>
    <script src="/js/data-table/bootstrap-table-resizable.js" th:src="@{/js/data-table/bootstrap-table-resizable.js}"></script>
    <script src="/js/data-table/colResizable-1.5.source.js" th:src="@{/js/data-table/colResizable-1.5.source.js}"></script>
    <script src="/js/data-table/bootstrap-table-export.js" th:src="@{/js/data-table/bootstrap-table-export.js}"></script>
    <!--  editable JS
        ============================================ -->
    <script src="/js/editable/jquery.mockjax.js" th:src="@{/js/editable/jquery.mockjax.js}"></script>
    <script src="/js/editable/mock-active.js" th:src="@{/js/editable/mock-active.js}"></script>
    <script src="/js/editable/select2.js" th:src="@{/js/editable/select2.js}"></script>
    <script src="/js/editable/moment.min.js" th:src="@{/js/editable/moment.min.js}"></script>
    <script src="/js/editable/bootstrap-datetimepicker.js" th:src="@{/js/editable/bootstrap-datetimepicker.js}"></script>
    <script src="/js/editable/bootstrap-editable.js" th:src="@{/js/editable/bootstrap-editable.js}"></script>
    <script src="/js/editable/xediable-active.js" th:src="@{/js/editable/xediable-active.js}"></script>

    <!-- tab JS
        ============================================ -->
    <script src="/js/tab.js" th:src="@{/js/tab.js}"></script>
    <!-- plugins JS
        ============================================ -->
    <script src="/js/plugins.js" th:src="@{/js/plugins.js}"></script>
    <!-- main JS
        ============================================ -->
    <script src="/js/main.js" th:src="@{/js/main.js}"></script>
</head>


<body>


                <form>
                    <div  class="form-group">
                        <label for="name" class="control-label">员工姓名：</label>
                        <input type="text" class="form-control" id="name">
                    </div>
                    <div class="form-group">
                        <label for="employeeId" class="control-label">员工编号：</label>
                        <input type="text" class="form-control" id="employeeId">
                    </div>
<!--                    <div class="form-group">-->
<!--                        <label >员工性别：</label><br/>-->
<!--                        <div class="form-check form-check-inline" >-->
<!--                            <input class="form-check-input" type="radio" name="gender"  id="gender1" value="男">-->
<!--                            <label class="form-check-label">男</label>-->
<!--                        </div>-->
<!--                        <div class="form-check form-check-inline">-->
<!--                            <input class="form-check-input" type="radio" name="gender" id="gender0" value="女">-->
<!--                            <label class="form-check-label">女</label>-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="form-group">
                        <label for="gender" class="control-label">员工性别：</label>
                        <input type="text" class="form-control" id="gender">
                    </div>
                    <div class="form-group">
                        <label for="idNumber" class="control-label">员工身份证号码：</label>
                        <input type="text" class="form-control" id="idNumber">
                    </div>
                    <div class="form-group">
                        <label for="birthday" class="control-label">员工出生日期：</label>
                        <input type="date" class="form-control" id="birthday">
                    </div>
                    <div class="form-group">
                        <label for="province" class="control-label">员工籍贯：</label>
                        <input type="text" class="form-control" id="province">
                    </div>
                    <div class="form-group">
                        <label for="tel" class="control-label">员工手机号码：</label>
                        <input type="text" class="form-control" id="tel">
                    </div>
                    <div class="form-group">
                        <label for="education" class="control-label">员工学历：</label>
                        <input type="text" class="form-control" id="education">
                    </div>
                    <div class="form-group">
                        <label for="post" class="control-label">员工职务：</label>
                        <input type="text" class="form-control" id="post">
                    </div>
                    <div class="form-group">
                        <label  class="control-label">员工所属部门：</label>
                        <select class="form-control" name="dept" id="dept"  >
                            <option value="销售部">销售部</option>
                            <option value="仓储部">仓储部</option>
                            <option value="售后部">售后部</option>
                        </select>

                    </div>
                    <div class="form-group">
                        <label for="salary" class="control-label">员工底薪：</label>
                        <input type="text" class="form-control" id="salary">
                    </div>
                </form>
            </div>
                <div>
                    <button type="submit" class="btn btn-primary" onclick="add();">添加</button>
                    <input type="button"  onclick="back();" th:value="返回"/>
                </div>



                <script th:inline="javascript">

                   back = function () {
                        window.history.go(-1);


                    }

                    add = function (){
                        var name = $("#name").val();
                        var employeeId = $("#employeeId").val();
                        var gender = $("#gender").val();
                        var idNumber = $("#idNumber").val();
                        var birthday = $("#birthday").val();
                        var province = $("#province").val();
                        var tel = $("#tel").val();
                        var education = $("#education").val();
                        var post = $("#post").val();
                        var dept = $("#dept").val();
                        var salary = $("#salary").val();
                        var identificationCode;
                        if(dept == "销售部"){
                            identificationCode = 1;
                        }else if(dept == "仓储部"){
                            identificationCode = 2;
                        }else{
                            identificationCode = 3;
                        }
                        $.ajax({
                            url : "/emp/insert",
                            type: "post",
                            data: {
                            "name": name,
                                "employeeId": employeeId,
                                "gender": gender,
                                "idNumber": idNumber,
                                "birthday": birthday,
                                "province": province,
                                "tel": tel,
                                "education": education,
                                "post": post,
                                "dept": dept,
                                "salary": salary,
                                "identificationCode" :identificationCode
                        },
                            success: function (data) {
                                console.log(data)
                                console.log("添加成功");
                                alert("添加成功！")
                    //
                                //返回员工列表
                                window.history.go(-1);
                            },
                            error: function () {
                                alert("添加失败！")
                            }
                    })
                    }

                </script>
</form>


</div>


</body>

</html>